// import com.alibaba.druid.sql.ast.SQLExpr;
// import com.alibaba.druid.sql.ast.SQLObject;
// import com.alibaba.druid.sql.ast.SQLObjectImpl;
// import com.alibaba.druid.sql.dialect.oracle.visitor.OracleASTVisitor;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.Collections;
// import java.util.List;

#include "OracleAnalyticWindowing.h"
#include "../../../../ast/SQLExpr.h"
#include "../../../../ast/SQLObject.h"
#include "../../visitor/OracleASTVisitor.h"
#include "../../../../visitor/SQLASTVisitor.h"

OracleAnalyticWindowing_Type_ptr OracleAnalyticWindowing_Type::ROWS = OracleAnalyticWindowing_Type_ptr(new OracleAnalyticWindowing_Type(1ULL << 0, make_string_ptr("ROWS")));
OracleAnalyticWindowing_Type_ptr OracleAnalyticWindowing_Type::RANGE = OracleAnalyticWindowing_Type_ptr(new OracleAnalyticWindowing_Type(1ULL << 1, make_string_ptr("RANGE")));

OracleAnalyticWindowing_Type::OracleAnalyticWindowing_Type(uint64_t mask, string_ptr name)
{
  this->mask = mask;
  this->name = name;
}

OracleAnalyticWindowing::OracleAnalyticWindowing()
{
}

// @Override
void OracleAnalyticWindowing::accept0(SQLASTVisitor_ptr visitor)
{
  this->accept0(std::dynamic_pointer_cast<OracleASTVisitor>(visitor));
}

void OracleAnalyticWindowing::accept0(OracleASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(OracleAnalyticWindowing)))
  {
    acceptChild(visitor, this->expr);
  }
  visitor->endVisit(SharedObject(OracleAnalyticWindowing));
}

SQLExpr_ptr OracleAnalyticWindowing::getExpr()
{
  return this->expr;
}

void OracleAnalyticWindowing::setExpr(SQLExpr_ptr expr)
{
  if (expr != nullptr)
  {
    expr->setParent(SharedObject(OracleAnalyticWindowing));
  }
  this->expr = expr;
}

OracleAnalyticWindowing_Type_ptr OracleAnalyticWindowing::getType()
{
  return this->type;
}

void OracleAnalyticWindowing::setType(OracleAnalyticWindowing_Type_ptr type)
{
  this->type = type;
}

// @Override
SQLObject_ptr OracleAnalyticWindowing::clone()
{
  SQLObject_ptr clone_tmp = std::shared_ptr<OracleAnalyticWindowing>(new OracleAnalyticWindowing());
  std::shared_ptr<OracleAnalyticWindowing> x = std::dynamic_pointer_cast<OracleAnalyticWindowing>(clone_tmp);
  // OracleAnalyticWindowing x = new OracleAnalyticWindowing();
  x->type = type;
  if (expr != nullptr)
  {
    x->setExpr(std::dynamic_pointer_cast<SQLExpr>(expr->clone()));
  }
  return x;
}

// @Override
SQLObject_list_ptr OracleAnalyticWindowing::getChildren()
{
  SQLObject_list_ptr children = std::make_shared<std::list<SQLObject_ptr>>();
  children->push_back(this->expr);
  return children;
}
